import pandas as pd

df = pd.DataFrame(
    {"语文": [67, 56, 100],
     "数学": [78, 79, 99],
     "英语": [99, 83, 98]},
    index=["张三", "李四", "王五"]
)
df1 = pd.DataFrame(
    {"语文": [67, 56, 100],
     "数学": [78, 79, 99],
     "英语": [99, 83, 98]},
index=["王六", "刘七", "赵八"]

)

df2 = pd.DataFrame(
    {"物理": [57, 56, 47],
     "化学": [68, 29, 39],
     "生物": [29, 33, 90]},
index=["张三", "李四", "王五"]
)

df3 = pd.DataFrame(
    {"物理": [57, 56, 47],
     "化学": [68, 29, 39],
     "生物": [29, 33, 90]},
    index=["王六", "刘七", "赵八"]
)


df_combined=pd.concat([df,df1])
print("\n多个表的结合:\n",df_combined)
df_transport=pd.melt(df_combined)
print("\n横纵轴转换:\n",df_transport)
df_chinese=df[["语文"]]
print("\n只调出语文的成绩:\n",df_chinese)
df_good=df.query("语文>60")
print("语文及格的成绩数据:\n",df_good)
df_line=df.iloc[0:2,[0,1]]
print("调出0,1列，0,1行的内容:\n",df_line)

print("每个科目成绩唯一值的行数统计：")
for subject in df_combined.columns:
    print(f"{subject}:")
    print(df_combined[subject].value_counts())

print("\n合并后 DataFrame 的行数：")
print(len(df_combined))

print("\n合并后 DataFrame 的行数和列数：")
print(df_combined.shape)

print("\n合并后各科目列中的不同值的数量：")
print(df_combined.nunique())

print("\n合并后每个列的基本描述性统计信息：")
print(df_combined.describe())

print("\n合并后各列的总和：")
print(df_combined.sum())

print("\n合并后各列的非 NA/null 值数量：")
print(df_combined.count())

print("\n合并后各列的中位数：")
print(df_combined.median())

print("\n合并后各列的 25% 和 75% 分位数：")
print(df_combined.quantile([0.25, 0.75]))

def square(x):
    return x ** 2


print("\n应用自定义函数（平方）到合并后的每列：")
print(df_combined.apply(square))

print("\n合并后各列的最小值：")
print(df_combined.min())

print("\n合并后各列的最大值：")
print(df_combined.max())

print("\n合并后各列的平均值：")
print(df_combined.mean())

print("\n合并后各列的方差：")
print(df_combined.var())

print("\n合并后各列的标准差：")
print(df_combined.std())